#include "f1.h"
#include "f2.h"
#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
int main()
{
	void *handle;
	void (*cosine)();
	char *error;
	
	void *f2_handle;
	void (*f2_test)();
	
	handle = dlopen ("../dyna_lib/libf1.so", RTLD_LAZY);
	if (!handle) {
        fprintf (stderr, "%s\n", dlerror());
        exit(1);
    }
	
	cosine = dlsym(handle, "f1_test");
    if ((error = dlerror()))  {
        fprintf (stderr, "%s\n", error);
        exit(1);
    }
	
	(*cosine)();
    dlclose(handle);
	
	f2_handle = dlopen ("../dyna_lib/libf2.so", RTLD_LAZY);
	if (!f2_handle) {
        fprintf (stderr, "%s\n", dlerror());
        exit(1);
    }
	printf("dlopen libf2 succes\n");
	f2_test = dlsym(f2_handle, "f2_test");
    if ((error = dlerror()))  {
        fprintf (stderr, "%s\n", error);
        exit(1);
    }
	(*f2_test)();
	dlclose(handle);
	return 0;
}